﻿
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Ace;
using Ace.Application.Common;
using Ace.Application.Wiki;
using Ace.Entity.Wiki;
using Ace.IdStrategy;
using Ace.Web.Mvc;
using Ace.Web.Mvc.Authorization;
using Ace.Web.Mvc.Models;
using Chloe.Admin.Common;
using Chloe.Admin.Common.Tree;
using Microsoft.AspNetCore.Mvc;

namespace Chloe.Admin.Areas.Wiki.Controllers
{

    [Area(AreaNames.Wiki)]
    [Permission("wiki.video")]
    public class VideoController : WebController<IVideoService>
    {
        public IActionResult Index()
        {
            ISortService SortService = this.CreateService<ISortService>();
            List<Sort> ListSort = SortService.GetList((int)EnumSort.Video, "");
            ViewBag.ListSort = ListSort;

            List<Sort> SortList = SortService.GetList((int)EnumSort.Video2, "");
            ViewBag.SortList = SortList;

            return View();
        }

        public ActionResult Models(Pagination pagination,int SortID=0, int ST=-1, string keyword="")
        { 

            PagedData<VideoInfo> pagedData = this.Service.GetVideoInfoPageData(pagination,1, SortID, ST, keyword);
            return this.SuccessData(pagedData);
        }


        [Permission("wiki.video.delete")]
        [HttpPost]
        public ActionResult Delete(string id)
        { 
            this.Service.Delete(id);
            return this.SuccessMsg("删除成功");
        }
         
 


        [Permission("wiki.video.edit")]
        [HttpPost]
        public ActionResult Edit(UpdateVideoInput modle)
        {            
            this.Service.Update(modle);
            return this.SuccessMsg("编辑成功");
        }

        [Permission("wiki.video.add")]
        [HttpPost]
        public ActionResult Add(AddVideoInput modle)
        {
            modle.CreateDate = DateTime.Now;
            modle.CreateID = this.CurrentSession.UserId;

            this.Service.Add(modle);
            return this.SuccessMsg("添加成功");
        }

    }
}